import { Component, OnInit } from '@angular/core';
import {
  PagedResultDto, ClassInfoOutput, PagerSearchInput, HttpService, BaseComponentConfig,
  CustomNavigation, KeyValueOutput, SearchValue
} from '../../..';
import { Router, Route, ActivatedRoute } from "@angular/router";
import { NzMessageService, NzNotificationService } from 'ng-zorro-antd';
@Component({
  selector: 'app-feedback-add',
  templateUrl: './feedback-add.component.html',
  styleUrls: ['./feedback-add.component.scss']
})
export class FeedbackAddComponent implements OnInit {
  feedtype: any;
  fwbBjq: "12";
  fwbBjq01: "12";
  feedtypeValue: "";
  constructor(private http: HttpService, private _message: NzMessageService, private router: Router) {

  }

  ngOnInit() {
    this.feedtype = [
      { "name": "使用体验反馈", "value": "使用体验反馈" },
      { "name": "软件问题反馈", "value": "软件问题反馈" },
      { "name": "建议优化反馈", "value": "建议优化反馈" },
    ];
  }

  keyupHandler(event) {
    this.fwbBjq = event;
  }
  resultFh() {
    this.router.navigate(['app/feedIndex/feedback']);
  }
  async saveFeed() {
    if (this.feedtypeValue === undefined) {
      this._message.warning("请选择反馈类型");
    } else if (this.fwbBjq === undefined) {
      this._message.warning("请填写反馈信息");
    } else {
      const data = { "FeedbackType": this.feedtypeValue, "information": this.fwbBjq };
      try {
       await this.http.post<any>("FeedbackInformationService/CreateInformation", data).then(e => {

        });
        this._message.success("反馈成功");
        this.router.navigate(['app/feedIndex/feedback']);
      } catch (error) {
        this._message.error("创建反馈信息失败");
      }
    }
  }

}
